package com.pi.stroop.service;

import java.util.List;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import com.pi.stroop.dao.entity.MemberPayRecordEntity;
import com.pi.stroop.dao.mapper.MemberPayRecordMapper;
import com.pi.stroop.dao.param.MemberPayRecordParam;

@Validated
@Service
public class MemberPayRecordService {
  
  @Autowired
  private MemberPayRecordMapper memberPayRecordMapper;
  
  public List<MemberPayRecordEntity> queryMemberPayRecord(
      @NotNull(message="STROOP_RECORD.USER_ID_IS_EMPTY") Long userId,
      @Max(value=500, message = "STROOP_RECORD.PAGE_SIZE_TOO_LARGE") Integer pageSize,
      @Max(value=1000, message = "STROOP_RECORD.START_ROW_TOO_LARGE") Integer pageNumber){
    MemberPayRecordParam param = new MemberPayRecordParam();
    param.setPageNumber(pageNumber);
    param.setPageSize(pageSize);
    return memberPayRecordMapper.findList(param);
  }
  
  public long countMemberPayRecord(
      @NotNull(message="STROOP_RECORD.USER_ID_IS_EMPTY") Long userId){
    return memberPayRecordMapper.count();
  }
}
